/**
 * Created by IntelliJ IDEA.
 * User: Bezdelnick
 * Date: 10/3/12
 * Time: 9:29 PM
 * To change this template use File | Settings | File Templates.
 */
package vplib.maple {
public class UniqueIdUtil {
    public function UniqueIdUtil() {
    }

    public static function validateUniqueId(id:String):String {
        var matches:Array = new Array();
        var exp:RegExp = null;

        exp = new RegExp("[\\w]*[:|;|!|@|#|$|%|^|&|*|(|)|/|\\|,|.][\\w]*");
        matches = id.match(exp);
        if (matches != null)
            if (matches[0] != null)
                if ((matches[0] as String).length > 0)
                    return "Use can use only letters, numbers and \"_\" (but not the other characters) for UniqueId.";

        exp = new RegExp("[\\w]*__[\\w]*");
        matches = id.match(exp);
        if (matches != null)
            if (matches[0] != null)
                if ((matches[0] as String).length > 0)
                    return "Use can not use \"__\" (double underscore) for UniqueId.";

//        exp = new RegExp("[\\d]*[\\w]*");
//        matches = id.match(exp);
//        if (matches != null)
//            if (matches[0] != null)
//                if ((matches[0] as String).length > 0)
//                    return "Use can not use \"0-9\" (numbers) for UniqueId.";

//        exp = new RegExp("[\\w|\\d|_]{20}");
//        id.match(exp);
//        if (matches != null)
//            if (matches[0] != null)
//                if ((matches[0] as String).length > 0) {
//                    trace("[UniqueIdUtility] \t- validateUniqueId - Successful validate uniqueId");
//                    return null;
//                }

//        return "Can not validate unique id.";
        return null;
    }
}
}
